<template>
  <el-dialog title="导入食谱" :visible.sync="dialogFormVisible1" >
    <el-upload
      class="upload-demo"
      :action="action"
      :on-preview="handlePreview"
      :on-remove="handleRemove"
      :before-remove="beforeRemove"
      :on-success="success"
      multiple
      :limit="3"
      :on-exceed="handleExceed">
      <el-button size="small" type="primary">点击上传</el-button>
    </el-upload>
  </el-dialog>
</template>

<script>

    export default {

        name: "SysUserEdit",
      data(){
          return{

            action:'/api/base/food_list/upload',
            formAdd:{
              name:'',
              summary:'',
            },
            form:{
              name:'',
              summary:'',
            },
            dialogFormVisible1: false,

            formLabelWidth: '120px'
          }
      },
      methods:{
        handleRemove(file, fileList) {
          console.log(file, fileList);
        },
        handlePreview(file) {
          console.log(file);
        },
        handleExceed(files, fileList) {
          this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
        },
        beforeRemove(file, fileList) {
          return this.$confirm(`确定移除 ${ file.name }？`);
        },

        success(){
          this.$emit('on-result-change')
          this.dialogFormVisible1 = false;
        },
          _open(obj){
            if (undefined===obj){

              this.form= JSON.parse(JSON.stringify(this.formAdd));;
              console.log('-----formAdd------',this.formAdd)
              this.dialogFormVisible1=true;
            }else{
              this.form=obj;
              this.dialogFormVisible1=true;
            }

          }
      },
    }
</script>

<style scoped>

</style>
